// 16

#pragma once
#include <netinet/in.h>//struct sockaddr_in
#include <string>

//封装socket地址类型
class InetAddress {
    public:
        explicit InetAddress(uint16_t port, std::string ip = "127.0.0.1");
        explicit InetAddress(const sockaddr_in& addr) : addr_(addr) {}

        std::string toIp() const;
        std::string toIpPort() const;
        uint16_t toPort() const;

        const sockaddr_in* getSockAddr() const {return &addr_;}
        void setSockAddr(const sockaddr_in &addr) { addr_ = addr; }


    private:
        //只支持ipv4
        sockaddr_in addr_;
};
